package cn.zw.netty;


import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import java.nio.ByteBuffer;
import java.nio.charset.Charset;

public class SimpleServerHander extends ChannelInboundHandlerAdapter {


    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
         if(msg instanceof ByteBuffer){
             System.out.println(((ByteBuf)msg).toString(Charset.defaultCharset()));
         }
        ByteBuf buf= Unpooled.buffer();
        buf.writeBytes("ssss".getBytes());
        ctx.writeAndFlush(buf);
    }
}
